package util;

import java.nio.charset.Charset;
import java.util.Scanner;
import java.util.Vector;

public class ListGroup {
	public Vector<String> vals = null;
	public String title;
	
	public ListGroup(Scanner s) throws Exception
	{
		//String title = Util.toUTF8(s.nextLine());
		String title = s.nextLine();
		
		if(title.startsWith("[") && title.endsWith("]"))
		{
			this.title = title.substring(1, title.length() - 1);
		}
		else
		{
			throw new Exception("No more groups");
		}
		
		vals = new Vector<String>();
		while(s.hasNext())
		{
			String tmp = s.nextLine();
			if(tmp.length() < 3) break;
			vals.add(tmp);
		}
	}
	
	public int getSize()
	{
		return vals.size();
	}
	
	public String get(int index)
	{
		return vals.get(index);
	}
	
	public Vector<String> getVector()
	{
		return vals;
	}
	
	public int getInt(int index)
	{
		int i = 0;
		try
		{
			i = Integer.parseInt(vals.get(index));
		}
		catch(Exception e) { i = 0; }
			
		return i;
	}
}
